<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
window.onload=function(){
	var oTab=document.getElementById('tab1');
	var oTxt=document.getElementById('name');
	var oBtn=document.getElementById('btn1');
	
	oBtn.onclick=function()
	{
		for(var i=0;i<oTab.tBodies[0].rows.length;i++)
		{
			var sTxt=oTxt.value.toLowerCase ();
			var sTab=oTab.tBodies[0].rows[i].cells[1].innerHTML.toLowerCase ();
			
			var arr=sTxt.split(' ');
			
			oTab.tBodies[0].rows[i].style.background='';
							
			for(var j=0;j<arr.length;j++)
			{
				if(sTab.search(arr[j])!=-1)//将字符串去全转为小写
				{
					oTab.tBodies[0].rows[i].style.background='red';
				}
			}
		}
	}
	
};
</script>
</head>

<body>
姓名：<input id="name" type="text" />
<input id="btn1" type="button" value="搜索" />
<table id="tab1" border="1" width="500">
	<thead>
    	<td>ID</td>
        <td>姓名</td>
        <td>年龄</td>
        <td>操作</td>
    </thead>
    <tbody>
    	<tr>
        	<td>1</td>
            <td>张三</td>
            <td>20</td>
            <td></td>
        </tr>
        <tr>
        	<td>2</td>
            <td>李四</td>
            <td>24</td>
            <td></td>
        </tr>
        <tr>
        	<td>3</td>
            <td>王五</td>
            <td>22</td>
            <td></td>
        </tr>
        <tr>
        	<td>4</td>
            <td>Blue</td>
            <td>23</td>
            <td></td>
        </tr>
        <tr>
        	<td>5</td>
            <td>张玮</td>
            <td>21</td>
            <td></td>
        </tr>
    </tbody>
</table>
</body>
</html>
